﻿using AiChiTu.TraceabilitySystem.Infrastructure.Implements;
using AiChiTu.TraceabilitySystem.Infrastructure.Interfaces;
using System.Reflection;

namespace AiChiTu.TraceabilitySystem.Read.API.ServersExtensions
{
	/// <summary>
	/// 扩展方法
	/// </summary>
	public static class ServersExtension
	{
		/// <summary>
		/// 注册服务扩展方法
		/// </summary>
		/// <param name="services"></param>
		/// <returns></returns>
		public static IServiceCollection AddServers(this IServiceCollection services)
		{
			// 注册泛型仓储服务
			services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>));
			// 注册映射轮廓服务
			services.AddAutoMapper(typeof(MappingProfiles));
			// 注册中介者服务
			services.AddMediatR(x => x.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));

			return services;
		}
	}
}
